﻿$(document).ready(function () {
    $(".verifycode").each(function () {
        $(this).attr("src", $(this).attr("dataurl") + "?" + Math.random());
    });

    $(".lbtn").each(function () { $(this).html("<span>" + $(this).html() + "</span>"); });

    $("input[type='text']").attr("autocomplete", "off");

    $(".ten-table tr").hover(function () { $(this).find("td").addClass("hover") }, function () { $(this).find("td").removeClass("hover") });

    $(".selectAll").click(function () { selectGroup(this); });

    $(".delete").click(function () { return confirm("确认要删除该项吗？"); });

    $(".selectDelete").click(function () {
        if (!confirm("确认要删除该项吗？")) return false;

        var group = $(this).attr("group");
        var array = new Array();
        $("input[group='" + group + "']").each(function () {
            var o = $(this);
            if (o.attr("checked") == true || o.attr("checked") == "checked") {
                if (o.val() != "on") array.push(o.val());
            }
        });

        $.post($(this).attr("href"), { "ids": "" + array + "" }, function () { location.href = location.href; });

        return false;
    });

    $("#loading").ajaxStart(function () { $(this).show() });
    $("#loading").ajaxStop(function () { $(this).hide() });

});

function selectGroup(obj) {
    var parent = $(obj);
    $("input[group='" + parent.attr("group") + "']").each(function () {
        $(this).attr("checked", parent.attr("checked"));
    });
}

function showDialog(html) {
    alert(html);
}

function addToFavorite() {
    var a = "http://www.jucache.com/";
    var b = "聚存-视频聚合缓存";
    if (document.all) { window.external.AddFavorite(a, b) }
    else if (window.sidebar) { window.sidebar.addPanel(b, a, "") }
    else { alert("对不起，您的浏览器不支持此操作!\n请您使用菜单栏或Ctrl+D收藏本站。") }
}

function changeVerifyCode(obj) {
    $(obj).attr("src", $(obj).attr("dataurl") + "?" + Math.random());
    $("#VerifyCode").focus();
}